package com.gogowan.agroenterprise.widget.adapter;

import java.util.List;

import com.gogowan.agroenterprise.R;
import com.gogowan.agroenterprise.model.CollectData;
import com.gogowan.agroenterprise.widget.adapter.InOutDetailAdapter.ViewHolder;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 标签采集扫码Adapter
 * 
 * @author app
 *
 */
public class CollectScanAdapter extends BaseAdapter {

	private List<CollectData> datas;

	private Context context;

	public CollectScanAdapter(List<CollectData> datas, Context context) {
		this.datas = datas;
		this.context = context;
	}

	@Override
	public int getCount() {
		return datas.size();
	}

	@Override
	public Object getItem(int position) {
		return datas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(R.layout.layout_collect_item, null);
			viewHolder.xh = (TextView) convertView.findViewById(R.id.xh);
			viewHolder.cpgg = (TextView) convertView.findViewById(R.id.cpgg);
			viewHolder.cpmc = (TextView) convertView.findViewById(R.id.cpmc);
			viewHolder.scsj = (TextView) convertView.findViewById(R.id.scsj);
			viewHolder.ewmbm = (TextView) convertView.findViewById(R.id.ewmbm);
			viewHolder.smsj = (TextView) convertView.findViewById(R.id.smsj);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.xh.setText(position + 1 + "");
		viewHolder.cpmc.setText(datas.get(position).getMaterialName() + "");
		viewHolder.cpgg.setText(datas.get(position).getMaterialSpection() + "");
		viewHolder.scsj.setText("");
		viewHolder.ewmbm.setText(datas.get(position).getCodeStr() + "");
		viewHolder.smsj.setText(datas.get(position).getScanTime() + "");
		return convertView;
	}

	static class ViewHolder {
		TextView xh;
		TextView cpmc;
		TextView cpgg;
		TextView scsj;
		TextView ewmbm;
		TextView smsj;
	}

}
